package com.woniuxy.service.impl;

import com.woniuxy.entity.SysOrganization;
import com.woniuxy.entity.SysTeam;
import com.woniuxy.mapper.SysTeamOrganizationMapper;
import com.woniuxy.service.SysTeamOrganizationService;
import com.woniuxy.util.ResponseEnum;
import com.woniuxy.util.ResponseUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统团队组织服务实现类
 * 实现系统团队组织相关的业务逻辑
 */
@Service
public class SysTeamOrganizationServiceImpl implements SysTeamOrganizationService {
    @Resource
    private SysTeamOrganizationMapper sysTeamOrganizationMapper;

    /**
     * 根据医生ID、角色、组织ID和团队名称查询系统团队
     * @param doctorId 医生ID
     * @param role 角色
     * @param orgId 组织ID
     * @param teamName 团队名称
     * @return 返回符合条件的系统团队信息
     */
    @Override
    public ResponseUtil findSysTeam(Integer doctorId, Integer role, Integer orgId, String teamName) {
        List<SysTeam> sysTeam = sysTeamOrganizationMapper
                .findSysTeam(doctorId, role, orgId, teamName);
        return sysTeam !=null?ResponseUtil.get(ResponseEnum.OK,sysTeam)
                :ResponseUtil.get(ResponseEnum.FAIL);
    }

    @Override
    public ResponseUtil findAllByOrgId(Integer orgId) {
        List<SysTeam> teams = sysTeamOrganizationMapper.findAllByOrgId(orgId);
        return teams !=null?ResponseUtil.get(ResponseEnum.OK, teams)
                :ResponseUtil.get(ResponseEnum.FAIL);
    }

    @Override
    public ResponseUtil findOrgByTeamId(Integer teamId) {
        SysOrganization organization = sysTeamOrganizationMapper.findOrgByTeamId(teamId);
        return organization != null ? ResponseUtil.get(ResponseEnum.OK, organization)
                : ResponseUtil.get(ResponseEnum.FAIL);
    }
}
